home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Nedd help in getting file-type
- Date: 10 Mar 1996 10:38:22 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4hv7iuINNq8s@keats.ugrad.cs.ubc.ca>
- References: <4hmooa$2i5@asterix.isd-pm.de>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4hmooa$2i5@asterix.isd-pm.de>,
- Guenter Saller <guenter@isd-pm.de> wrote:
- >Hi there,
- >
- >I got a problem how to get the file-type in a c-programm.
- >
- >Especially I had to recognice a EDCBIC-file.
- >
- >My question:
- >
- > Is there any systemcall on SINIX 5.42 which returns the file-type?
-
- Ask in comp.unix.programmer, this is not a C question.
-
- Some file systems have meta-information about files which includes types. The
- metainformation stored in typical UNIX filesystems does not carry type (but
- does carry things like time/date stamps, permissions, ownership, etc).
-
- There is a convention that the first two characters of a file form a magic
- number which identifies the type. For example, the characters #! indicate an
- interpreter file. Executables and object files have their own magic numbers.
-
- The ``file'' utility program looks at the magic numbers (and other clues where
- magic numbers are lacking) to try to guess the file type. This program can be
- flexibly configured to recognize new file types via the /etc/magic
- configuration file.
-
- If you want to recognize a particular file type, have a look at /etc/magic and
- the kinds of heuristics that implementations of ``file'' apply in trying to
- detect a particular file type.
-
- Assuming that you only want to distinguish between EBCDIC and ASCII files, you
- can scan the first few characters and apply some sort of heuristic rule of
- thumb to guess which kind you are dealing with. If you know something about
- the kind of information that these files are expected to contain, that can help
- you as well.
- --
-
-